package com.woniu.service.contentService.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;


import com.woniu.mapper.contentService.AdvertisementDtoMapper;
import com.woniu.model.contentMService.dto.AdvertisementDto;
import com.woniu.service.contentService.AdvertisementDtoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
@Service
public class AdvertisementDtoImpl implements AdvertisementDtoService {

    @Autowired
    private AdvertisementDtoMapper advertisementDtoMapper;
//    @Override
//    public PageInfo<AdvertisementDto> findByPage(Map<String, Object> condition) {
//        //1.设置PageHelper参数
//        PageHelper.startPage(condition); //自动从对象中找pageNum和pageSize的参数去分页
//        //2.调用DAO层查询所有的记录
//        List<AdvertisementDto> list = advertisementDtoMapper.findByPage(condition);
//        //3.返回PageInfo对象
//        return new PageInfo<>(list);
//    }

    @Override
    public PageInfo<AdvertisementDto> findByPage(Map<String, Object> condition, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<AdvertisementDto> list = advertisementDtoMapper.findByPage(condition);
        return new PageInfo<>(list);
    }
}
